package com.mocha.mybatis.config;

import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import com.mocha.common.kits.IdWorker;
import com.mocha.common.kits.RandomKits;


public class MochaIdentifierGenerator implements IdentifierGenerator {

    private static final IdWorker ID_WORKER = new IdWorker(RandomKits.randomLong(~(-1 << 10)));

    @Override
    public boolean assignId(Object idValue) {
        return IdentifierGenerator.super.assignId(idValue);
    }

    @Override
    public Number nextId(Object entity) {
        return ID_WORKER.nextId();
    }

    @Override
    public String nextUUID(Object entity) {
        return IdentifierGenerator.super.nextUUID(entity);
    }
}
